import axios from '@/utils/request'

export const getArticleList = (id, timestamp) => {
  return axios({
    method: 'get',
    url: '/v1_1/articles',
    params: {
      channel_id: id,
      timestamp,
      with_top: 1
    }
  })
}

export const dislikeArticle = id => {
  return axios({
    method: 'POST',
    url: '/v1_0/article/dislikes',
    data: {
      target: id
    }
  })
}

/* 举报文章 */
export const reportArticle = (id, type) => {
  return axios({
    method: 'POST',
    url: '/v1_0/article/reports',
    data: {
      target: id,
      type
    }
  })
}

/* 拉黑用户 */
export const blackUser = id => {
  return axios({
    method: 'POST',
    url: '/v1_0/user/blacklists',
    data: {
      target: id
    }
  })
}

/* 获取文章详情 */
export const getArticleDetail = id => {
  return axios({
    method: 'get',
    url: '/v1_0/articles/' + id
  })
}

/* 关注用户 */
export const followUser = id => {
  return axios({
    method: 'post',
    url: '/v1_0/user/followings',
    data: {
      target: id
    }
  })
}

/* 取消关注用户 */
export const unFollowUser = id => {
  return axios({
    method: 'delete',
    url: '/v1_0/user/followings/' + id
  })
}

/**
 * 取消点赞
 * @param {*} id 文章编号
 */
export const deleteLike = id => {
  return axios({
    method: 'delete',
    url: '/v1_0/article/likings/' + id
  })
}

/**
 * 添加点赞
 * @param {*} id 文章编号
 */
export const addLike = id => {
  return axios({
    method: 'post',
    url: '/v1_0/article/likings',
    data: {
      target: id
    }
  })
}
